From 7d9077c9a94997743e3df090fa682ebaf8ee62c0 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Thu, 28 Nov 2024 17:53:24 +0800 Subject: [PATCH] Use unique_ptr over scoped pointer take is deprecated in scoped pointer Signed-off-by: Claudio Cambra f handle Signed-off-by: Claudio Cambra Use unique_ptr instead of scoped pointer for propagator firstJob Fixes deprecation warning Signed-off-by: Claudio Cambra Use unique_ptr for discoveryphase, replace take with release Fix deprecation warn Signed-off-by: Claudio Cambra f unique Signed-off-by: Claudio Cambra --- src/csync/vio/csync_vio_local_unix.cpp | 5 ++-- src/gui/wizard/flow2authwidget.cpp | 15 ++++++------ src/gui/wizard/flow2authwidget.h | 2 +- src/libsync/owncloudpropagator.cpp | 4 ++-- src/libsync/owncloudpropagator.h | 2 +- src/libsync/syncengine.cpp | 32 +++++++++++++------------- src/libsync/syncengine.h | 2 +- 7 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/csync/vio/csync_vio_local_unix.cpp b/src/csync/vio/csync_vio_local_unix.cpp index ec47ab3c7..8f319a3e4 100644 --- a/src/csync/vio/csync_vio_local_unix.cpp +++ b/src/csync/vio/csync_vio_local_unix.cpp @@ -52,8 +52,7 @@ struct csync_vio_handle_t { static int _csync_vio_local_stat_mb(const mbchar_t *wuri, csync_file_stat_t *buf); csync_vio_handle_t *csync_vio_local_opendir(const QString &name) { - QScopedPointer handle(new csync_vio_handle_t{}); - + auto handle = std::make_unique(); auto dirname = QFile::encodeName(name); handle->dh = _topendir(dirname.constData()); @@ -62,7 +61,7 @@ csync_vio_handle_t *csync_vio_local_opendir(const QString &name) { } handle->path = dirname; - return handle.take(); + return handle.release(); } int csync_vio_local_closedir(csync_vio_handle_t *dhandle) { diff --git a/src/gui/wizard/flow2authwidget.cpp b/src/gui/wizard/flow2authwidget.cpp index 87f63d591..cb9262846 100644 --- a/src/gui/wizard/flow2authwidget.cpp +++ b/src/gui/wizard/flow2authwidget.cpp @@ -65,19 +65,20 @@ void Flow2AuthWidget::setLogo() void Flow2AuthWidget::startAuth(Account *account) { - Flow2Auth *oldAuth = _asyncAuth.take(); - if(oldAuth) + const auto oldAuth = _asyncAuth.release(); + if (oldAuth) { oldAuth->deleteLater(); + } _statusUpdateSkipCount = 0; if(account) { _account = account; - _asyncAuth.reset(new Flow2Auth(_account, this)); - connect(_asyncAuth.data(), &Flow2Auth::result, this, &Flow2AuthWidget::slotAuthResult, Qt::QueuedConnection); - connect(_asyncAuth.data(), &Flow2Auth::statusChanged, this, &Flow2AuthWidget::slotStatusChanged); - connect(this, &Flow2AuthWidget::pollNow, _asyncAuth.data(), &Flow2Auth::slotPollNow); + _asyncAuth = std::make_unique(_account, this); + connect(_asyncAuth.get(), &Flow2Auth::result, this, &Flow2AuthWidget::slotAuthResult, Qt::QueuedConnection); + connect(_asyncAuth.get(), &Flow2Auth::statusChanged, this, &Flow2AuthWidget::slotStatusChanged); + connect(this, &Flow2AuthWidget::pollNow, _asyncAuth.get(), &Flow2Auth::slotPollNow); _asyncAuth->start(); } } @@ -122,7 +123,7 @@ void Flow2AuthWidget::setError(const QString &error) { Flow2AuthWidget::~Flow2AuthWidget() { // Forget sensitive data - _asyncAuth.reset(); + _asyncAuth.reset(nullptr); } void Flow2AuthWidget::slotOpenBrowser() diff --git a/src/gui/wizard/flow2authwidget.h b/src/gui/wizard/flow2authwidget.h index 2660ff0b7..4c622fab3 100644 --- a/src/gui/wizard/flow2authwidget.h +++ b/src/gui/wizard/flow2authwidget.h @@ -49,7 +49,7 @@ Q_SIGNALS: private: Account *_account = nullptr; - QScopedPointer _asyncAuth; + std::unique_ptr _asyncAuth; Ui_Flow2AuthWidget _ui{}; protected Q_SLOTS: diff --git a/src/libsync/owncloudpropagator.cpp b/src/libsync/owncloudpropagator.cpp index 5e4c5fa25..dac9a0e60 100644 --- a/src/libsync/owncloudpropagator.cpp +++ b/src/libsync/owncloudpropagator.cpp @@ -1352,7 +1352,7 @@ PropagateDirectory::PropagateDirectory(OwncloudPropagator *propagator, const Syn , _subJobs(propagator) { if (_firstJob) { - connect(_firstJob.data(), &PropagatorJob::finished, this, &PropagateDirectory::slotFirstJobFinished); + connect(_firstJob.get(), &PropagatorJob::finished, this, &PropagateDirectory::slotFirstJobFinished); _firstJob->setAssociatedComposite(&_subJobs); } connect(&_subJobs, &PropagatorJob::finished, this, &PropagateDirectory::slotSubJobsFinished); @@ -1395,7 +1395,7 @@ bool PropagateDirectory::scheduleSelfOrChild() void PropagateDirectory::slotFirstJobFinished(SyncFileItem::Status status) { - _firstJob.take()->deleteLater(); + _firstJob.release()->deleteLater(); if (status != SyncFileItem::Success && status != SyncFileItem::Restoration diff --git a/src/libsync/owncloudpropagator.h b/src/libsync/owncloudpropagator.h index 1a96ece64..ad1911111 100644 --- a/src/libsync/owncloudpropagator.h +++ b/src/libsync/owncloudpropagator.h @@ -315,7 +315,7 @@ class OWNCLOUDSYNC_EXPORT PropagateDirectory : public PropagatorJob public: SyncFileItemPtr _item; // e.g: create the directory - QScopedPointer _firstJob; + std::unique_ptr _firstJob; PropagatorCompositeJob _subJobs; diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp index 8d4915b48..f691ce09d 100644 --- a/src/libsync/syncengine.cpp +++ b/src/libsync/syncengine.cpp @@ -637,7 +637,7 @@ void SyncEngine::startSync() _remnantReadOnlyFolders.clear(); - _discoveryPhase.reset(new DiscoveryPhase); + _discoveryPhase = std::make_unique(); _discoveryPhase->_leadingAndTrailingSpacesFilesAllowed = _leadingAndTrailingSpacesFilesAllowed; _discoveryPhase->_account = _account; _discoveryPhase->_excludes = _excludedFiles.data(); @@ -679,17 +679,17 @@ void SyncEngine::startSync() _discoveryPhase->_serverBlacklistedFiles = _account->capabilities().blacklistedFiles(); _discoveryPhase->_ignoreHiddenFiles = ignoreHiddenFiles(); - connect(_discoveryPhase.data(), &DiscoveryPhase::itemDiscovered, this, &SyncEngine::slotItemDiscovered); - connect(_discoveryPhase.data(), &DiscoveryPhase::newBigFolder, this, &SyncEngine::newBigFolder); - connect(_discoveryPhase.data(), &DiscoveryPhase::existingFolderNowBig, this, &SyncEngine::existingFolderNowBig); - connect(_discoveryPhase.data(), &DiscoveryPhase::fatalError, this, [this](const QString &errorString, ErrorCategory errorCategory) { + connect(_discoveryPhase.get(), &DiscoveryPhase::itemDiscovered, this, &SyncEngine::slotItemDiscovered); + connect(_discoveryPhase.get(), &DiscoveryPhase::newBigFolder, this, &SyncEngine::newBigFolder); + connect(_discoveryPhase.get(), &DiscoveryPhase::existingFolderNowBig, this, &SyncEngine::existingFolderNowBig); + connect(_discoveryPhase.get(), &DiscoveryPhase::fatalError, this, [this](const QString &errorString, ErrorCategory errorCategory) { Q_EMIT syncError(errorString, errorCategory); finalize(false); }); - connect(_discoveryPhase.data(), &DiscoveryPhase::finished, this, &SyncEngine::slotDiscoveryFinished); - connect(_discoveryPhase.data(), &DiscoveryPhase::silentlyExcluded, + connect(_discoveryPhase.get(), &DiscoveryPhase::finished, this, &SyncEngine::slotDiscoveryFinished); + connect(_discoveryPhase.get(), &DiscoveryPhase::silentlyExcluded, _syncFileStatusTracker.data(), &SyncFileStatusTracker::slotAddSilentlyExcluded); - connect(_discoveryPhase.data(), &DiscoveryPhase::remnantReadOnlyFolderDiscovered, this, &SyncEngine::remnantReadOnlyFolderDiscovered); + connect(_discoveryPhase.get(), &DiscoveryPhase::remnantReadOnlyFolderDiscovered, this, &SyncEngine::remnantReadOnlyFolderDiscovered); ProcessDirectoryJob *discoveryJob = nullptr; @@ -724,27 +724,27 @@ void SyncEngine::startSync() }(); discoveryJob = new ProcessDirectoryJob( - _discoveryPhase.data(), + _discoveryPhase.get(), pinState, path, singleItemDiscoveryOptions().discoveryDirItem, {}, localQueryMode, _journal->keyValueStoreGetInt("last_sync", 0), - _discoveryPhase.data() + _discoveryPhase.get() ); } else { discoveryJob = new ProcessDirectoryJob( - _discoveryPhase.data(), + _discoveryPhase.get(), PinState::AlwaysLocal, _journal->keyValueStoreGetInt("last_sync", 0), - _discoveryPhase.data() + _discoveryPhase.get() ); } _discoveryPhase->startJob(discoveryJob); connect(discoveryJob, &ProcessDirectoryJob::etag, this, &SyncEngine::slotRootEtagReceived); - connect(_discoveryPhase.data(), &DiscoveryPhase::addErrorToGui, this, &SyncEngine::addErrorToGui); + connect(_discoveryPhase.get(), &DiscoveryPhase::addErrorToGui, this, &SyncEngine::addErrorToGui); } void SyncEngine::slotFolderDiscovered(bool local, const QString &folder) @@ -910,7 +910,7 @@ void SyncEngine::finalize(bool success) _stopWatch.stop(); if (_discoveryPhase) { - _discoveryPhase.take()->deleteLater(); + _discoveryPhase.release()->deleteLater(); } s_anySyncRunning = false; _syncRunning = false; @@ -1369,8 +1369,8 @@ void SyncEngine::abort() } else if (_discoveryPhase) { // Delete the discovery and all child jobs after ensuring // it can't finish and start the propagator - disconnect(_discoveryPhase.data(), nullptr, this, nullptr); - _discoveryPhase.take()->deleteLater(); + disconnect(_discoveryPhase.get(), nullptr, this, nullptr); + _discoveryPhase.release()->deleteLater(); qCInfo(lcEngine) << "Aborting sync in discovery..."; finalize(false); } diff --git a/src/libsync/syncengine.h b/src/libsync/syncengine.h index 63ab0a787..2dc5bfa6b 100644 --- a/src/libsync/syncengine.h +++ b/src/libsync/syncengine.h @@ -339,7 +339,7 @@ private: QString _remotePath; QByteArray _remoteRootEtag; SyncJournalDb *_journal; - QScopedPointer _discoveryPhase; + std::unique_ptr _discoveryPhase; QSharedPointer _propagator; QSet _bulkUploadBlackList; -- 2.30.2